﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy1_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                this.Icon = new Icon("icon.ico");

                this.BackgroundImage = Image.FromFile("load.jpg");
                this.BackgroundImageLayout = ImageLayout.Stretch;

                label1.Visible = false;
                this.Text = "窗体事件演示 - 已载入";
            }
            catch (Exception ex)
            {
                MessageBox.Show("图片加载失败: " + ex.Message, "错误",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Form1_Click(object sender, EventArgs e)
        {
            try
            {
                this.BackgroundImage = Image.FromFile("click.jpg");
                this.BackgroundImageLayout = ImageLayout.Stretch;

                label1.Visible = false;

                this.Text = "窗体事件演示 - 单击状态";

                
            }
            catch (Exception ex)
            {
                MessageBox.Show("图片加载失败: " + ex.Message, "错误",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                this.BackgroundImage = Image.FromFile("Images/doubleclick.jpg");
                this.BackgroundImageLayout = ImageLayout.Stretch;

                label1.Visible = true;

                this.Text = "窗体事件演示 - 双击状态";

                
            }
            catch (Exception ex)
            {
                MessageBox.Show("图片加载失败: " + ex.Message, "错误",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("标签被点击了！当前标签可见性: " + label1.Visible,
                "标签事件", MessageBoxButtons.OK, MessageBoxIcon.Information);

            {

            }
        }
    }
}
